package com.hui10.mediaplayer.base

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.hui10.mediaplayer.ui.activity.MainActivity
import org.jetbrains.anko.AnkoLogger
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast

/**
 * Author: Created by lucus on 2019/5/23.
 * E-mail: mcphilex1989@gmail.com
 * Tel: 15652608401
 * Activity基类
 */
abstract class BaseActivity : AppCompatActivity(), AnkoLogger {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getLayoutId())
        initListener()
        initData()
    }

    /**
     * 初始化数据
     */
    open protected fun initData() {

    }

    /**
     * 初始化adapter listener
     */
    open protected fun initListener() {

    }

    /**
     * 初始化布局id
     */
    abstract fun getLayoutId(): Int

    /**
     * 弹吐司
     */
    protected fun showT(msg: String) {
        runOnUiThread {
            toast(msg)
        }
    }

    inline fun <reified T : BaseActivity> startActivityAndFinish() {
        startActivity<T>()
        finish()
    }


}